<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>mymsgro</title>
	<link rel="stylesheet" type="text/css" href="css/main.css" />
	<link rel="stylesheet" type="text/css" href="css/meniu.css" />
	<link rel="stylesheet" type="text/css" href="css/style.css" />

</h:head>
<h:body>

	<ui:include src="header.xhtml" />

	<h:panelGroup layout="block" id="content">

		<ui:include src="leftMenu.xhtml" />

		<h:panelGroup layout="block" id="contenRight">
	<f:event type="preRenderView" listener="#{employeeBean.preRenderView}"/>
			<h:panelGroup layout="block" id="header" style="margin-top: 20px;">
				<ul>
					<li id="selected"><a>Add trainee</a></li>
				</ul>
			</h:panelGroup>
			
			

			<h:panelGroup layout="block" id="contentTab">
			
			<h:outputText value="#{employeeBean.errorMsg}" style="color:red"/>
				<h:form id="formAddUser" enctype="multipart/form-data">
					<h:panelGrid columns="3">


						<h:outputText value="#{employeeBean.successMessage}"
							style="color:red" />
						<h:outputText />
						<h:outputText />
						<h:outputText />
						
						<h:outputText value="Username:" style="float: right" />

						<h:inputText id="inputUsername" value="#{traineeDTO.username}"
							required="true" requiredMessage="Can't be blank" styleClass="inputEmployee">
						</h:inputText>
						<h:message for="inputUsername" style="color:red" />

						<h:outputText value="First name:" style="float: right" />
						<h:inputText id="inputFirstname" value="#{traineeDTO.firstname}"
							required="true" requiredMessage="Can't be blank" styleClass="inputEmployee"/>
						<h:message for="inputFirstname" style="color:red" />

						<h:outputText value="Last name:" style="float: right" />
						<h:inputText id="inputLastname" value="#{traineeDTO.lastname}"
							required="true" requiredMessage="Can't be blank" styleClass="inputEmployee"/>
						<h:message for="inputLastname" style="color:red" />

						<h:outputText value="Work email:" style="float: right" />
						<h:inputText id="inputWorkEmail" value="#{traineeDTO.workEmail}"
							required="true" validatorMessage="Email address is not valid"
							requiredMessage="Can't be blank" styleClass="inputEmployee">
							<f:validateRegex
								pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" />
						</h:inputText>
						<h:message for="inputWorkEmail" style="color:red" />

						<h:outputText value="Date of birth:" style="float: right" />


						<p:calendar effect="explode" value="#{traineeDTO.dob}"
							readonlyInput="true" timeZone="#{calendarBean.timeZone}"
							navigator="true" mindate="1900-01-01"
							maxdate="#{calendarBean.dateNow}" required="true"
							requiredMessage="Can't be blank"
							yearRange="1914:#{calendarBean.dateNow}" pattern="yyyy-MM-dd"
							id="popupButtonCal1" />

						<h:message for="popupButtonCal1" style="color:red" />

						<h:outputText value="Personal phone:" style="float: right" />
						<h:inputText id="inputPersonalPhone"
							value="#{traineeDTO.personalPhone}" required="true"
							validatorMessage="Phone number is not valid. It needs to be between 10 and 14 digits."
							requiredMessage="Can't be blank" styleClass="inputEmployee"/>
						<h:message for="inputPersonalPhone" style="color:red" />

						<h:outputText value="Personal email:" style="float: right" />
						<h:inputText id="inputPersonalEmail"
							value="#{traineeDTO.personalEmail}" required="true"
							validatorMessage="Email address is not valid"
							requiredMessage="Can't be blank" styleClass="inputEmployee">
							<f:validateRegex
								pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" />
						</h:inputText>
						
						
						<h:message for="inputPersonalEmail" style="color:red" />
						<h:outputText value="Employment date:" style="float: right" />
						<p:calendar effect="explode" value="#{traineeDTO.employmentDate}"
							readonlyInput="true" timeZone="#{calendarBean.timeZone}"
							navigator="true" mindate="1900-01-01"
							maxdate="#{calendarBean.dateNow}" required="true"
							requiredMessage="Can't be blank"
							yearRange="1914:#{calendarBean.dateNow}" pattern="yyyy-MM-dd"
							id="popupButtonCal2" />
						<h:message for="popupButtonCal2" style="color:red" />


						<h:outputText value="Last medical check date:"
							style="float: right" />
						<p:calendar effect="explode" value="#{traineeDTO.medCheckUpDate}"
							readonlyInput="true" timeZone="#{calendarBean.timeZone}"
							navigator="true" mindate="1900-01-01"
							maxdate="#{calendarBean.dateNow}" required="true"
							requiredMessage="Can't be blank"
							yearRange="1914:#{calendarBean.dateNow}" pattern="yyyy-MM-dd"
							id="popupButtonCal3" />
						<h:message for="popupButtonCal2" style="color:red" />
						
						<h:outputText value="Employment type:" style="float: right" />
						<h:selectOneMenu id="inputEmploymentType"
							value="#{traineeDTO.employmentType}">
							<f:selectItem itemValue="CM" itemLabel="CM" />
							<f:selectItem itemValue="PFA" itemLabel="PFA" />
						</h:selectOneMenu>
						<h:message for="inputEmploymentType" />

						<h:outputText value="Position:" style="float: right" />
						<h:inputText id="inputPosition" value="#{traineeDTO.position}"
							required="true" requiredMessage="Can't be blank" styleClass="inputEmployee"/>
						<h:message for="inputPosition" />

						<h:outputText value="CV:" style="float: right" />
						<h:inputFile id="uploadedFile" name="uploadFile"
							validator="#{employeeBean.validate}" />
						<h:outputText value="#{employeeBean.errorMessage}" />

						<h:outputText value="Salary" style="float: right" />
						<h:inputText id="inputSalary" value="#{traineeDTO.salary}"
							required="true" requiredMessage="Can't be blank" styleClass="inputEmployee"/>
						<h:message for="inputSalary" style="color:red" />

						<h:outputText rendered="#{traineeDTO.photo != null and searchUserBean.showPhoto == true}" value="Photo:" style="float: right" />
						
						<p:graphicImage rendered="#{traineeDTO.photo != null and searchUserBean.showPhoto == true}" value="#{employeeBean.byteArrayStringTrainee}" width="200" />
						<h:outputText rendered="#{traineeDTO.photo != null and searchUserBean.showPhoto == true}"></h:outputText>
						
						<h:outputText rendered="#{traineeDTO.photo == null and searchUserBean.showPhoto == true}" value="Photo:" style="float: right" />
						
						<h:graphicImage rendered="#{traineeDTO.photo == null and searchUserBean.showPhoto == true}" value="/resources/img/blankProfile.jpeg" width="200"/>
						<h:outputText rendered="#{traineeDTO.photo == null and searchUserBean.showPhoto == true}"></h:outputText>

						<h:outputText value="New Photo:" style="float: right" />
						<p:fileUpload fileUploadListener="#{employeeBean.photoSave}"
							mode="advanced" dragDropSupport="false" multiple="true"
							update="messages" sizeLimit="1000000" fileLimit="3"
							allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />
						<p:growl id="messages" showDetail="true" />
						

						<h:outputText value="Roles:" style="float: right" />
						<h:outputText />
						<h:outputText />

						<h:outputText value="Basic user (library and review)"
							style="float: right" />
						<h:selectBooleanCheckbox id="inputBasicUser"
							value="#{employeeBean.basicUser}" />
						<h:outputText />

						<h:outputText />
						<h:commandButton id="createUser" value="Save"
							action="#{employeeBean.addEmployee}">
							<f:param name="cicic" value="trainee" />
						</h:commandButton>

					</h:panelGrid>

				</h:form>
			</h:panelGroup>
		</h:panelGroup>
	</h:panelGroup>
</h:body>
</html>